var t = getApp().util;
var util = getApp().util
Page({
    data: {
        beginDate: "",
        endDate: ""
    },
    onLoad: function(t) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return util.shareSet(this, "");
    },
    searchUrl: function() {
        var t = this.data.beginDate, e = this.data.endDate;
        t && e ? wx.redirectTo({
            url: "../search/search?beginDate=" + JSON.stringify(t) + "&endDate=" + JSON.stringify(e)
        }) : wx.showToast({
            title: "请选择日期",
            icon: "none",
            duration: 2e3
        });
    },
    beginDate: function() {
        var e = this.data.beginDate;
        "" == e && (e = t.curRiqi()), this.setData({
            dateType: 1
        });
        var a = this.selectComponent("#bottomDialog"), i = [];
        a._getYear(function(t, n) {
            t ? console.log(t) : a._getMonth(e[0], function(t, o) {
                t ? console.log(t) : (i.push(n.indexOf(e[0])), i.push(o.indexOf(e[1])), i.push(parseInt(e[2]) - 1), 
                a.setData({
                    title: "起始日期",
                    years: n,
                    months: o,
                    modelType: "date",
                    dateIndex: i,
                    hideFlag: !1
                }), a.showModal());
            });
        });
    },
    endDate: function() {
        var e = this.data.endDate;
        "" == e && (e = t.curRiqi()), this.setData({
            dateType: 2
        });
        var a = this.selectComponent("#bottomDialog"), i = [];
        a._getYear(function(t, n) {
            t ? console.log(t) : a._getMonth(e[0], function(t, o) {
                t ? console.log(t) : (i.push(n.indexOf(e[0])), i.push(o.indexOf(e[1])), i.push(parseInt(e[2]) - 1), 
                a.setData({
                    title: "结束日期",
                    years: n,
                    months: o,
                    modelType: "date",
                    dateIndex: i,
                    hideFlag: !1
                }), a.showModal());
            });
        });
    },
    riqiSure: function(e) {
        if (1 == this.data.dateType) (i = this.data.endDate) && t.riqiTime(e.detail.join("/")) > t.riqiTime(i.join("/")) && this.setData({
            endDate: ""
        }), this.setData({
            beginDate: e.detail
        }); else if ("" != a) {
            var a = this.data.beginDate.join("/"), i = e.detail.join("/");
            if (t.riqiTime(i) < t.riqiTime(a)) return void wx.showToast({
                title: "结束日期必须大于开始日期",
                icon: "none",
                duration: 2e3
            });
            this.setData({
                endDate: e.detail
            });
        } else this.setData({
            endDate: e.detail
        });
    }
});